<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>商品管理</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="../../../component/elementUI/index.css">
    <link rel="stylesheet" href="../../../style/wangeditor.css">
    <link rel="stylesheet" href="../../../style/index.css">
    <style>
        .el-badge__content{
            z-index: 1;
        }
        .el-dialog__header {
            padding: 15px 15px 10px;
        }

        .el-dialog__body {
            padding: 15px;
        }

        .el-dialog__footer {
            padding: 5px 15px 10px;
        }

        #user .el-dialog{
            margin-top:10px!important;
            margin: 0 auto 10px;
        }

        #user .el-dialog__header {
            padding: 15px 15px 0;
        }

        #user .el-dialog__body {
            padding: 0 15px 0;
        }
        
        #user .el-input.is-disabled .el-input__inner {
            color: #000;
            background-color: #fff;
        }
    </style>
</head>

<body>
    <div id="app" v-cloak class="minWidth">
        <el-form :inline="true" :form="form">
            <el-form-item>
                <el-button type="primary" @click="Add">新增</el-button>
            </el-form-item>
            <el-form-item>
                <el-input v-model.trim="form.Article_SerialNumber" clearable placeholder="请输入商品内码"/>
            </el-form-item>
            <el-form-item>
                <el-input v-model.trim="form.Article_Name" clearable placeholder="请输入商品名称"/>
            </el-form-item>
            <el-form-item>
                <el-input v-model.trim="form.Supplier_Name" clearable placeholder="请输入供应商名称"/>
            </el-form-item>
            <el-form-item>
                <el-select clearable v-model.trim="form.Brand_SerialNumber" placeholder="请选择商品品牌" filterable style="width: 100%">
                    <el-option v-for="(item,index) in brand" :key="index" :label="item.Brand_Name" :value="item.Brand_SerialNumber"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item>
                <el-select clearable v-model.trim="form.Shelf" clearable placeholder="请选择商品状态" filterable style="width: 100%">
                    <el-option label="已上架" value="0"></el-option><el-option label="已下架" value="1"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item>
                <el-cascader v-model="business_article_classify" clearable placeholder="请选择分类汇总" filterable collapse-tags
                    :props="defaultProps" :options="classify" style="width: 100%"></el-cascader>
            </el-form-item>
            <el-form-item>
                <el-row style="width: 217px;">
                    <el-col :span="11">
                        <el-input v-model.trim="form.gross_margin1" clearable placeholder="毛利率%" />
                    </el-col>
                    <el-col style="text-align: center;" :span="2">-</el-col>
                    <el-col :span="11">
                        <el-input v-model.trim="form.gross_margin2" clearable placeholder="毛利率%" />
                    </el-col>
                </el-row>
            </el-form-item>
            <el-form-item>
                <el-row style="width: 217px;">
                    <el-col :span="11">
                        <el-input v-model.trim="form.discount1" clearable placeholder="商品折扣%" />
                    </el-col>
                    <el-col style="text-align: center;" :span="2">-</el-col>
                    <el-col :span="11">
                        <el-input v-model.trim="form.discount2" clearable placeholder="商品折扣%" />
                    </el-col>
                </el-row>
            </el-form-item>
            <el-form-item>
                <el-row style="width: 217px;">
                    <el-col :span="11">
                        <el-input v-model.trim="form.Purchase_Unit_Price1" clearable placeholder="一件代发价" />
                    </el-col>
                    <el-col style="text-align: center;" :span="2">-</el-col>
                    <el-col :span="11">
                        <el-input v-model.trim="form.Purchase_Unit_Price2" clearable placeholder="一件代发价" />
                    </el-col>
                </el-row>
            </el-form-item>
            <el-form-item>
                <el-row style="width: 217px;">
                    <el-col :span="11">
                        <el-input v-model.trim="form.Sales_Unit_Price1" clearable placeholder="平台价" />
                    </el-col>
                    <el-col style="text-align: center;" :span="2">-</el-col>
                    <el-col :span="11">
                        <el-input v-model.trim="form.Sales_Unit_Price2" clearable placeholder="平台价" />
                    </el-col>
                </el-row>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="onSerach">查询</el-button>
            </el-form-item>
            <el-form-item>
                <el-button type="success" :loading="loading" @click="Export(form)">商品导出</el-button>
            </el-form-item>
            <el-form-item>
                <el-dropdown trigger="click" @command="handleBatchAdd">
                    <el-button type="primary">
                        批量生/失效<i class="el-icon-arrow-down el-icon--right"></i>
                    </el-button>
                    <el-dropdown-menu slot="dropdown">
                        <el-dropdown-item command="1">批量生效</el-dropdown-item>
                        <el-dropdown-item command="0">批量失效</el-dropdown-item>
                    </el-dropdown-menu>
                </el-dropdown>
            </el-form-item>
            <el-form-item>
                <el-dropdown trigger="click" @command="downloadTemplate">
                    <el-button type="primary">
                        下载导入模板<i class="el-icon-arrow-down el-icon--right"></i>
                    </el-button>
                    <el-dropdown-menu slot="dropdown">
                        <el-dropdown-item command="Article">商品模板</el-dropdown-item>
                        <el-dropdown-item command="BarCode">条码模板</el-dropdown-item>
                        <el-dropdown-item command="UpData">更新商品模板</el-dropdown-item>
                    </el-dropdown-menu>
                </el-dropdown>
            </el-form-item>
            <el-form-item>
                <el-dropdown trigger="click" @command="importTemplate">
                    <el-button type="danger">
                        批量导入<i class="el-icon-arrow-down el-icon--right"></i>
                    </el-button>
                    <el-dropdown-menu slot="dropdown">
                        <el-dropdown-item command="Article">导入商品数据</el-dropdown-item>
                        <el-dropdown-item command="BarCode">导入商品条码</el-dropdown-item>
                        <el-dropdown-item command="UpData">导入更新商品模板</el-dropdown-item>
                    </el-dropdown-menu>
                </el-dropdown>
            </el-form-item>
            <el-form-item>
                <el-button :loading="downloadImagesLoading" @click="handleImages" type="primary">批量下载图片<i class="el-icon-download el-icon--right"></i></el-button>
            </el-form-item>
            <el-form-item>
                <el-badge :value="count" :max="99" class="item">
                    <el-button @click="examine">审核</el-button>
                </el-badge>
            </el-form-item>
            <el-form-item>
                <el-button @click="log">审核记录</el-button>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="()=>{this.$refs.multipleTable.clearSelection()}">清空已选</el-button>
            </el-form-item>
        </el-form>
        <!-- 表格 -->
        <el-table ref="multipleTable" :data="tableData" stripe border height="calc(100vh - 270px)" style="width: 100%" :reserve-selection="true"   @selection-change="handleSelectionChange" :row-key="row=>row.Supplier_Article_SerialNumber">
            <el-table-column align="center" :reserve-selection="true" type="selection" width="40"></el-table-column>
            <el-table-column align="center" type="index" label="序号" width="50"></el-table-column>
            <el-table-column prop="Article_SerialNumber" width="150" label="商品内码"></el-table-column>
            <el-table-column prop="Picture_URL" width="140" align="center" label="商品封面">
                <template v-slot="{row}">
                    <el-image fit="contain" :src="BASE_IMG + row.Picture_URL" :preview-src-list="[BASE_IMG + row.Picture_URL]" style="width:100px;height: 100px;"></el-image>
                </template>
            </el-table-column>
            <el-table-column prop="Article_Name" width="150" label="商品名称"></el-table-column>
            <el-table-column prop="Specifications_Name"  width="150"  label="商品规格"></el-table-column>
            <el-table-column prop="Brand_Name" width="150" label="品牌"></el-table-column>
            <el-table-column prop="Classify_Name" width="200" label="商品分类">
                <template v-slot="{row}">
                    <el-tag size="mini" v-for="(item,index) in row.Classify_Name?row.Classify_Name.split(';'):[]" :key="index">{{item}}</el-tag>
                </template>
            </el-table-column>
            <el-table-column prop="Supplier_Name" width="100" label="供应商"></el-table-column>
            <el-table-column prop="Staples_Code1" width="150" label="A公司编码">
                <template v-slot="{row}">
                    <div v-if="!row.is1" style="display: flex;align-items: center;">
                        <i @click="row.is1 = true" class="el-icon-edit" style="cursor: pointer;color: red;"></i> <span>{{row.Staples_Code1?row.Staples_Code1:'暂无A公司编码'}}</span>
                    </div>
                    <div v-else>
                        <i @click="handleStaplesCode1(row)" class="el-icon-finished" style="cursor: pointer;color: red;"></i>
                        <el-input size="mini" style="width:110px" v-model="row.Staples_Code1" placeholder="请输入A公司编码"></el-input>
                    </div>
                </template>
            </el-table-column>
            <el-table-column prop="Staples_Code2" width="150" label="B公司编码">
                <template v-slot="{row}">
                    <div v-if="!row.is2">
                        <i @click="row.is2 = true" class="el-icon-edit" style="cursor: pointer;color: red;"></i> <span>{{row.Staples_Code2?row.Staples_Code2:'暂无B公司编码'}}</span>
                    </div>
                    <div v-else>
                        <i @click="handleStaplesCode2(row)" class="el-icon-finished" style="cursor: pointer;color: red;"></i>
                        <el-input size="mini" style="width:110px" v-model="row.Staples_Code2" placeholder="请输入B公司编码"></el-input>
                    </div>
                </template>
            </el-table-column>
            <el-table-column align="center" prop="Purchase_Unit_Price" width="120" label="一件代发价"></el-table-column>
            <el-table-column align="center" prop="Sales_Unit_Price" width="120" label="平台价"></el-table-column>
            <el-table-column align="center" label="折扣率">
                <template v-slot="{row}">
                    {{row.JDCOM_Unit_Price1>0&&row.Sales_Unit_Price>0?(accDiv(row.Sales_Unit_Price,row.JDCOM_Unit_Price1)*100).toFixed(2) + '%':'-'}}
                </template>
            </el-table-column>
            <el-table-column align="center" label="毛利率">
                <template v-slot="{row}">
                    {{row.Purchase_Unit_Price>0&&row.Sales_Unit_Price>0?(accSub(1,accDiv(row.Purchase_Unit_Price,row.Sales_Unit_Price))*100).toFixed(2)+'%':'-'}}
                </template>
            </el-table-column>
            <el-table-column prop="JDCOM_URL" width="150" label="京东链接">
                <template v-slot="{row}">
                    <span style="cursor: pointer;" @click="handleJD(row.JDCOM_URL)">{{row.JDCOM_URL}}</span>
                </template>
            </el-table-column>
            <el-table-column prop="JDCOM_Unit_Price" label="京东价"></el-table-column>
            <el-table-column prop="Stock_Remain" width="120" label="今日剩余库存"></el-table-column>
            <el-table-column align="center" prop="Group" width="120" label="是否参与团购"></el-table-column>   
            <el-table-column align="center" prop="Shelf" width="120" label="是否生效">
                <template v-slot="{row}">
                    {{row.Shelf == '0'?'已生效':'未生效'}}
                </template>
            </el-table-column>
            <el-table-column  align="center" label="操作" width="180">
                <template v-slot="{row}">
                    <el-button type="success" size="small" @click="Show(row)">详情</el-button>
                    <el-dropdown size="small" trigger="click"  @command="moreConfig($event,row)">
                        <el-button size="small" type="primary">
                            更多<i class="el-icon-arrow-down el-icon--right"></i>
                        </el-button>
                        <el-dropdown-menu slot="dropdown">
                            <el-dropdown-item command="Edit">编辑</el-dropdown-item>
                            <!-- <el-dropdown-item command="Shelf">{{row.Shelf=='0'?'生效':'失效'}}</el-dropdown-item>
                            <el-dropdown-item command="Remove">删除</el-dropdown-item> -->
                            <el-dropdown-item command="Download0">下载主图</el-dropdown-item>
                            <el-dropdown-item command="Download1">下载详情图</el-dropdown-item>
                        </el-dropdown-menu>
                    </el-dropdown>
                </template>
            </el-table-column>
        </el-table>
        <el-pagination style="margin-top: 5px;" background @size-change="handleSizeChange"
            @current-change="handleCurrentChange" :current-page="form.page" :page-sizes="[10, 20, 30, 50]"
            :page-size="form.limit" layout="total, sizes, prev, pager, next, jumper" :total="total">
        </el-pagination>
        <show-detail :visible.sync="dialogVisible" :data="Article_SerialNumber"></show-detail>
    </div>
    <script type="text/javascript" src="../../../utils/wangeditor.js"></script>
    <script type="text/javascript" src="../../../utils/jquery.min.js"></script>
    <script type="text/javascript" src="../../../utils/jquery.cookie.js"></script>
    <script type="text/javascript" src="../../../utils/vue.min.js"></script>
    <script type="text/javascript" src="../../../utils/vuex.min.js"></script>
    <script type="text/javascript" src="../../../component/elementUI/index.js"></script>
    <script type="text/javascript" src="../../../component/component.js"></script>
    <script type="text/javascript" src="../../../config/config.js"></script>
    <script type="text/javascript" src="../../../utils/FileSaver.min.js"></script>
    <script type="text/javascript" src="../../../utils/FileSaver.js"></script>
    <script type="text/javascript" src="../../../utils/xlsx.full.min.js"></script>
    <script type="text/javascript" src="../../../utils/xlsx.core.min.js"></script>
    <script type="text/javascript" src="../../../utils/compressor.js"></script>
    <script type="text/javascript" src="../../../utils/ID_Validity.js"></script>
    <script type="text/javascript" src="../../../utils/utils.js"></script>
    <script type="text/javascript" src="js/index.js"></script>
</body>

</html>